﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using Guolian.GForce.Extensions.EFCore;
//using Microsoft.EntityFrameworkCore;
//using Microsoft.Extensions.Configuration;

//namespace Guolian.ProjectName.Infrastruct
//{
//    public class ApiDbContext : DbContextBase<ApiDbContext>
//    {
//        public ApiDbContext(DbContextOptions<ApiDbContext> options) : base(options)
//        {
//        }
//        protected override void OnModelCreating(ModelBuilder modelBuilder)
//        {

//        }
//        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
//        {
//            base.OnConfiguring(optionsBuilder);
//            var config = new ConfigurationBuilder()
//                .SetBasePath(Directory.GetCurrentDirectory())
//                .AddJsonFile("appsettings.json")
//                .Build();
//            var databaseType = config.GetConnectionString("IsMySql");
//            if (databaseType == null) throw new ArgumentNullException(nameof(databaseType));
//            var databaseVersion = config.GetConnectionString("DataBaseType");
//            if (databaseVersion == null) throw new ArgumentNullException(nameof(databaseVersion));
//            if (bool.Parse(databaseType))
//                optionsBuilder.UseMySql(config.GetConnectionString("DefaultDataBase"), new MySqlServerVersion(new Version(databaseVersion)));
//        }
//    }
//}
